import type { ResponseOption } from "../../res/ResponseOption.js";
import { fields, ResOp } from "./utils.js";

export const launch: ResponseOption = {
    name: "0x00 01 响应启动信息",
    description: "响应启动信息",
    fields: [
        fields.op(ResOp.Launch),
        fields.crc,
        fields.length,
        {
            name: "工程名",
            kind: "string",
            length: 16,
        },
        {
            name: "索引寄存器",
            kind: "custom",
            desc: "每两个字节为一个索引",
            matcher(data) {
                let len = data.u16le(0);
                data.consume(2);
                const str = data.hex(len);
                data.consume(len);
                return len + " byte\n" + str;
            },
        },
        {
            name: "状态寄存器",
            kind: "custom",
            desc: "每两个字节为一个状态",
            matcher(data) {
                let len = data.u16le();
                data.consume(2);
                const str = data.hex(len);
                data.consume(len);
                return len + " byte\n" + str;
            },
        },
    ],
};
